package com.adk.backend.controller;

import com.adk.backend.common.Result;
import com.adk.backend.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 搜索中心控制器
 */
@Slf4j
@RestController
@RequestMapping("/search")
public class SearchController {
    
    @Autowired
    private SearchService searchService;
    
    /**
     * 根据订单号或订单ID搜索订单详情
     */
    @GetMapping("/order")
    public Result<Map<String, Object>> searchOrder(
            @RequestParam(required = false) String orderNo,
            @RequestParam(required = false) Long orderId) {
        return Result.success(searchService.searchOrder(orderNo, orderId));
    }
    
    /**
     * 根据装柜号搜索海运费用
     */
    @GetMapping("/loading")
    public Result<Map<String, Object>> searchLoadingNo(@RequestParam String loadingNo) {
        return Result.success(searchService.searchLoadingNo(loadingNo));
    }
    
    /**
     * 根据订单号或订单ID搜索贸易订单详情
     */
    @GetMapping("/trade-order")
    public Result<Map<String, Object>> searchTradeOrder(
            @RequestParam(required = false) String orderNo,
            @RequestParam(required = false) Long orderId) {
        return Result.success(searchService.searchTradeOrder(orderNo, orderId));
    }
}

